import { getAllDeptInfo } from "@/api/dept";
const state = {
  departments: [],
};

const actions = {
  async getAllDept({ commit }) {
    //发送请求
    try {
      let res = await getAllDeptInfo();
      commit("GETALLDEPT", res.data);
    } catch (e) {
      // 错误处理
    }
  },
};

const mutations = {
  GETALLDEPT(state, dept) {
    console.log(dept);
    state.departments = dept || [];
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
